

#include <iostream>
using namespace std;

//int main()
//{
//	int* ptr1 = new int;
//	int* ptr2 = new int(2);
//	int* ptr3 = new int[3];
//	int* ptr4 = new int[3]{1};
//
//	delete ptr1;
//	delete ptr2;
//	delete[] ptr3;
//	delete[] ptr4;
//
//	return 0;
//}

class A
{
public:
	A(int a = 1)
		:_a(a)
	{
		cout << "A():" << this << endl;
	}

	~A()
	{
		cout << "~A()" << this << endl;
	}

private:
	int _a;
};

int main()
{
	A* p1 = (A*)malloc(sizeof(A));
	A* p2 = new A(2);
	free(p1);
	delete p2;
	cout << endl;

	int* p3 = (int*)malloc(sizeof(int));
	int* p4 = new int(4);
	free(p3);
	delete p4;
	cout << endl;

	A* p5 = (A*)malloc(sizeof(A) * 5);
	A* p6 = new A[5]{1, 2, 3, 4, 5};
	free(p5);
	delete[] p6;
	cout << endl;

	return 0;
}